import {actList,releaseView} from '@/pages/api/index.js'
export default{
		data() {
		return {
			formAct:{
				order:'',       //活动编号
				platform:'',    //店铺
				state:'',       //状态
				startTime:'',   //开始时间
				endTime:'',      //结束时间
				pageSize:10,
				pageIndex:1
			},
			times:[],
			dataList:[],
			total:0,
			isLayer:false,
			isQuit:false,
			currentPage1: 5,
			currentPage2: 5,
			currentPage3: 5,
			currentPage4: 4,
			optionsStore: [{
			  value: '1',
			  label: '淘宝'
			}, {
			  value: '2',
			  label: '天猫'
			}, {
			  value: '3',
			  label: '京东'
			}, {
			  value: '4',
			  label: '拼多多'
			}],
			optionsState: [{
        value:'-1',
        label:'已取消'
      },{
				value: '0',
				label: '待付款'
			}, {
				value: '1',
				label: '等待区域'
			}, {
				value: '2',
				label: '进行中'
			}, {
				value: '3',
				label: '已完成'
			}],
			value4:'',
			value5: [new Date(2000, 10, 10, 10, 10), new Date(2000, 10, 11, 10, 10)],
				tableData2: [{
					actType: '普通评价单',
					antistop: '超强浴霸',
					sendNum: 10,
					principal:11,
					commission:12,
					insurance:13,
					serverGold:14
				}, {
					actType: '普通评价单',
					antistop: '超强浴霸',
					sendNum: 10,
					principal:11,
					commission:12,
					insurance:13,
					serverGold:14
        }],
        dialogVisible: false,
        layList:[],         //弹出框中所有数据
        gridData: [],      //弹出框中表格数据
        sendNum:0,          //发单数
        totalCapital:0,     //总本金
        totalCommission:0,  //总佣金
        totalInsurance:0,   //总保险
        allPrice:0,      //总价
		}
		},
		methods: {
			//搜索
			  searchAct(){
					  this.formAct.startTime = this.times[0]
						this.formAct.endTime = this.times[1]
						// console.log(this.times,1234)
						// this.formAct.startTime = datefilter(this.times[0])
						// this.formAct.endTime = datefilter(this.times[1])
						// this.times = datefilter(this.times)
             console.log(this.times)
					  this.init()
				},
				init(){
					 actList(this.formAct).then(res=>{
		          res.data.goods.forEach((item,index)=>{
                if(item.state == -1){
                    item.state = '已取消'
                }else if(item.state==0){
									 item.state = '待付款'
								 }else if(item.state==1){
									 item.state = '等待区域'
								 }else if(item.state==2){
									 item.state = '进行中'
								 }else{
									 item.state = '已完成'
								 }
							})
					 		this.dataList = res.data.goods
					 		this.total = res.data.count
					 		console.log(res.data)
					 }).catch(error=>{
						 console.log(error,'error')
					 })
				},
			  handleSizeChange(val) {
				    console.log(`每页 ${val} 条`);
						this.formAct.pageSize = val
						this.init()
			  },
			  handleCurrentChange(val) {
				    console.log(`当前页: ${val}`);
						this.formAct.pageIndex = val
						this.init()
			  },
			  handleClick(row) {
            console.log(row);
            this.allPrice = 0
           releaseView({goodId:row.id}).then(res=>{
               console.log(res,'res')
               if(res.code == 0){
                   this.layList = res.data
                   res.data.data.forEach(item => {
                       if(item.mold == 1){
                           item.mold = '原价单'
                       }else if(item.mold == 2){
                           item.mold = '评价单'
                       }else {
                           item.mold = '优惠券单'
                       }
                       this.gridData = res.data.data
                      //  this.sendNum = Number(item.num)
                      //  this.totalCapital +=Number(item.true_pay)
                      //  this.totalCommission += Number(item.store_commission)
                      //  this.totalInsurance += Number(item.insurance_money)
                      //  this.allPrice = this.sendNum * this.totalCapital + this.totalCommission + this.totalInsurance
                       this.allPrice += parseFloat(item.num) * parseFloat(item.true_pay) + parseFloat(item.store_commission) + parseFloat(item.insurance_money)

                   })
                  //  console.log(this.totalCapital.join(),23)
                  }else{

               }
           })
           this.dialogVisible =  true

         },
			  quit(){
           this.dialogVisible =  true
        },
        handleClose(done) {
          this.$confirm('确认关闭？')
            .then(_ => {
              done();
            })
            .catch(_ => {});
        }
    },
		created(){
			  this.init()
		}
	}
